<template>
	<div class="view">
		<template>
			<Top :title="'求职者信息审核'"></Top>
		</template>
		<div class="main">
			<div class="main_con">
				<div class="main_title">求职者信息审核</div>
				<div class="main_view">
					<el-form label-position="top" :model="form" ref="form">
						<el-form-item label="姓名" prop="title">
							<el-input class="input" v-model="form.name" :disabled="true"></el-input>
						</el-form-item>
						<el-form-item label="性别" prop="sex">
							<el-input class="input" v-model="form.sex" :disabled="true"></el-input>
						</el-form-item>
						<el-form-item label="头像:" style="margin-right: 20px;">
							<div v-if="!form.avatar">
								<el-upload :action="img_upload" list-type="picture-card" :auto-upload="false"
									:limit="1" :disabled="true">
									<i slot="default" class="el-icon-plus"></i>
									<div slot="file" slot-scope="{file}">
										<img class="el-upload-list__item-thumbnail" src="" alt="">
									</div>
								</el-upload>
							</div>
							<div class="img_box" v-else>
								<img class="el-upload-list__item-thumbnail" :src="$api.imgUrl+form.avatar" alt="">
							</div>
						</el-form-item>
						
						
						<el-form-item label="生日" prop="birthday">
							<el-input class="input" v-model="form.birthday" :disabled="true"></el-input>
						</el-form-item>
						<el-form-item label="学校"  prop="school">
							<el-input class="input" v-model="form.school" :disabled="true"></el-input>
						</el-form-item>
						<el-form-item label="专业"  prop="major">
							<el-input class="input" v-model="form.major" :disabled="true"></el-input>
						</el-form-item>
						<el-form-item label="学历" prop="education">
							<el-input type="input" class="input" v-model="form.education" :disabled="true"></el-input>
						</el-form-item>
						<el-form-item label="电话" prop="tel">
							<el-input type="input" class="input" v-model="form.tel" :disabled="true"></el-input>
						</el-form-item>
						<el-form-item label="微信" prop="wechat">
							<el-input type="input" class="input" v-model="form.wechat" :disabled="true"></el-input>
						</el-form-item>
						<el-form-item label="邮箱" prop="email">
							<el-input type="input" class="input" v-model="form.email" :disabled="true"></el-input>
						</el-form-item>
						<el-form-item label="所属行业" prop="hangye">
							<el-input type="input" class="input" v-model="form.hangye" :disabled="true"></el-input>
						</el-form-item>
						<el-form-item label="意向岗位" prop="gangwei">
							<el-input type="input" class="input" v-model="form.gangwei" :disabled="true"></el-input>
						</el-form-item>
						<el-form-item label="个人简介" prop="cnt">
							<el-input type="textarea" :rows="5"  v-model="form.cnt" style="width: 400px;" :disabled="true"></el-input>
						</el-form-item>

						<el-form-item label="申请日期">
							<el-date-picker v-model="form.timeCreate" type="date" :default-value="new Date()"
								style="width: 400px;" align="center" placeholder="选择日期时间" value-format="yyyy-MM-dd" :disabled="true">
							</el-date-picker>
						</el-form-item>
						
					</el-form>

				</div>
				<div class="saveBtn">
					<el-button type="primary" size="medium" @click="command(0)" :disabled="isAdd" v-if="this.form.status!=0">审核通过</el-button>
					<el-button type="danger" size="medium" @click="command(2)" :disabled="isAdd" v-if="this.form.status!=2">审核拒绝</el-button>
				</div>
			</div>

			<!--查看大封面-->
		<el-dialog title="查看大封面" :visible.sync="imgVisible" center :close-on-click-modal="false">
			<img :src="$api.imgUrl+imgName" v-if="imgVisible" style="width: 100%" alt="查看">
		</el-dialog>

		<!-- <input type="file" accept="image/*" style="position: absolute;z-index: -10;" ref="imgFile" @change="imgFileChange"> -->
		<FileUpload @fileChange="imgFileChange" ref="imgFile" accept="image/*"></FileUpload>

		</div>
	</div>
</template>

<script>
import Top from "../../components/top.vue";
import Ueditor from "../../components/ueditor.vue"
import { eduList, expList } from "@/util/data.js"
import FileUpload from "@/components/FileUpload.vue"
import { mapState } from "vuex"
export default {
	components: {
		Top, Ueditor,
		FileUpload
	},
	data() {
		return {
			form: {
				id: 0,         //主键
				avatar:'',
				name:'',
				sex:'',
				birthday:'',
				school:'',
				major:'',
				education:'',
				tel:'',
				wechat:'',
				email:'',
				zhengshu:'',
				gangwei:'',
				cnt:'',
				hangye:'',
				status:''
			},
			roleList: [],
			isAdd: false,
			eduList: eduList,
			expList: expList,
			
			//裁切图片参数
			cropperModel: false,
			cropperName: '',
			imgName: '',
			imgVisible: false,
			// mode: [120, 120],
			p_index: "",
			img_upload: "",

		}
	},
	computed: {
		...mapState(['urlParma'])
	},
	methods: {
		// 保存表单验证
		command(item) {
			// this.$refs['form'].validate((valid) => {
			// 	if (valid) {
					this.isAdd = true
					this.save(item)
			// 	}
			// });
		},

		// 保存
		save(item) {
			

			this.$http({
				'method': 'post',
				'url': this.$api.seekerStatus,
				data: {
					id:this.form.id,
					status:item
				}
			}).then(res => {
				if (res.data.code == 20000) {
					this.$message.success(res.data.message)
					this.$router.go(-1)
				} else {
					this.$message.error(res.data.message)
				}
				this.isAdd = false
			})
		},
		// 图片放大
		imgBig(type) {
			if (type == '1') {
				this.imgName = this.form.logo
			} else if (type == '2') {
				this.imgName = this.form.picdir
			}
			this.imgVisible = true
		},

		imgFileChange(data) {
			if (this.p_index == '1') {
				this.form.logo = data
			} else if (this.p_index == '2') {
				this.form.picdir = data
			} else {
				this.form.picdir = data
			}
		},

		fileChange() {
			let file = this.$refs.file.files[0];
			this.form.dataurlFname = file.name;
			let param = new FormData();
			param.append("file", file)
			this.$http({
				method: 'post',
				url: this.$api.uploadFile,
				data: param
			}).then(res => {
				if (res.data) {
					this.form.dataurl = res.data;
					this.$refs.file.value = "";
				} else {
					this.$message.error("上传文件失败！")
				}
			})
		},

		// 图片删除
		imgRemove(type) {
			if (type == '1') {
				this.form.logo = ""
			} else if (type == '2') {
				this.form.picdir = ""
			} else {
				this.form.picdir = ""
			}
		},

		// 图片上传
		uploadPicture(name, p_index) {
			this.p_index = p_index
			this.$refs.imgFile.open();
		},

		//图片上传成功后
		handleUploadSuccess(data) {
			this.cropperModel = false;
			this.cropperName = '';
			
		},

		// 获取组列表
		dataInit() {
			this.$http({
				'method': 'get',
				'url': this.$api.seekerDetail + this.urlParma.id,
			}).then(res => {
				if (res.data.code == 20000) {
					let { detail } = res.data.data;
					this.form = detail
				}
			})
		},

	},
	created() {
		this.dataInit()
	}
}
</script>

<style scoped>
@import url(../../assets/css/userAdd.css);
</style>
